package pers.lance.merchant.dao;

import org.springframework.stereotype.Repository;
import pers.lance.merchant.pojo.Customer;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

/**
 * @ Author     ：LILA3
 * @ Date       ：Created in 8:50 PM 7/30/2018
 */
@Repository
public class CustomerDaoImpl implements CustomerDao {
    @PersistenceContext(name = "em")
    EntityManager em;

    @Override
    public Customer insert(Customer customer) {
        em.persist(customer);
        return customer;
    }

    @Override
    public List<Customer> finAll() {
        return em
                .createQuery("from Customer")
                .getResultList();
    }
}
